#include "Client.h"

pair<string, string> Client::readConf(){
    // 打开文件读取 IP 和端口
    ifstream ifs("../conf/client.conf");
    if(!ifs.good()) {
        cout << "Open client.conf error!" << endl;
        exit(1);
    }
    pair<string, string> netCon;        
    ifs >> netCon.first;
    ifs >> netCon.second; 
    ifs.close();
    return netCon; 
}


void Client::Socket(){
    _fd = ::socket(AF_INET, SOCK_STREAM, 0);
    if(_fd < 0){
        perror("socket");
        return;
    }
}


void Client::TcpConnect(InetAddress &addr){
    printf("客户端正在等待连接!\n"); 
    int retval = ::connect(_fd, (struct sockaddr*)addr.getInetAddrPtr(), sizeof(addr));    
    if(retval == -1){
        perror("client connect");
        return ;
    }
    printf("连接成功!\n");
}
